﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DALScolarite;
namespace Scolarite
{
    public partial class EtudiantsParModules : Form
    {
        public EtudiantsParModules()
        {
            InitializeComponent();
        }

        private void EtudiantsParModules_Load(object sender, EventArgs e)
        {
            scolarite_eltdiplome eltdip = new scolarite_eltdiplome();
         
            scolariteanneeunivBindingSource.DataSource = GlobalParams.MonDbcontext.scolarite_anneeuniv.ToList();
            scolariteeltdiplomeBindingSource.DataSource = eltdip.diplome();


        }

        private void button1_Click(object sender, EventArgs e)
        {
            int idgroupe;
            int.TryParse(GroupecomboBox.SelectedValue.ToString(), out idgroupe);

            scolarite_enseigneunite ens = new scolarite_enseigneunite();

            etudiantModulesBindingSource.DataSource = ens.Etudiants(idgroupe,idEltDiplomeComboBox.SelectedValue.ToString(),ModulecomboBox1.SelectedValue.ToString());
        }

        private void idEltDiplomeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (idEltDiplomeComboBox.SelectedValue != null)
            {
                scolarite_classes cls = new scolarite_classes();
                scolariteclassesBindingSource.DataSource = cls.classe(idEltDiplomeComboBox.SelectedValue.ToString());

                scolarite_ensunites ensunit = new scolarite_ensunites();
                scolariteensunitesBindingSource.DataSource = ensunit.unite(idEltDiplomeComboBox.SelectedValue.ToString());
            }
        }

        private void idClasseComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (idClasseComboBox.SelectedValue != null)
            {
                scolarite_groupeclass grp = new scolarite_groupeclass();
                scolaritegroupeclassBindingSource.DataSource = grp.groupeclasse(idClasseComboBox.SelectedValue.ToString());
            }
        }

        private void GroupecomboBox_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
